Skip to content

Exclude totally empty subplots #2855

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Oct 23, 2020
Merged

Conversation

nicholas-esterer
Copy link
Contributor

@nicholas-esterer nicholas-esterer commented Oct 22, 2020

closes #2854
We should be able to select subplots containing anything, and also added is the feature to select subplots containing any combination of traces, shapes, annotations or layout_images.

It is now called _subplot_not_empty and selector can be used to choose
what is meant by non-empty.

The prior tests pass, but new tests for the subset selection criteria
have to be introduced.
This tests go.Figure._subplot_not_empty
@@ -1302,7 +1302,7 @@ def _add_annotation_like(
# if exclude_empty_subplots is True, check to see if subplot is
# empty and return if it is
if exclude_empty_subplots and (
not self._subplot_contains_trace(xref, yref)
not self._subplot_not_empty(xref, yref, selector=exclude_empty_subplots)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

does this line mean that one could do fig.add_shape( ... , row="all", col="all", exclude_empty_subplots=["traces", "shapes"]) ?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

to be clear: i don't think that's necessary, I would just do True/False here :)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You could but by default True means "all". I also don't think it's necessary but you get this functionality for free, all that needs to happen is the list of objects to check is made into the keyword argument of the function (and coerced to "all" if it is True). But I can disable that if you want and have it just accept True/False.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, let's just accept truthy/falsey for now. I think it's easier to not support certain exotic use-cases that then some people depend upon later :)

@nicolaskruchten
Copy link
Contributor

Also: could you please add a CHANGELOG entry in this PR that covers the previous one's features?

That means that truthy values exclude subplots containing absolutely
nothing (but not those containing shapes, but no traces, say) and
anything falsey adds to all subplots.
included entries for `exclude_empty_sublots`, for the
add_{hline,vline,hrect,vrect} commands, and `row="all"`, `col="all"`.
@nicholas-esterer
Copy link
Contributor Author

OK! should be ready for review.

@nicolaskruchten nicolaskruchten merged commit c83efb4 into master Oct 23, 2020
@archmoj archmoj deleted the exclude-totally-empty-subplots branch November 23, 2021 23:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants